package model

import "github.com/doujunyu/gogo/sql_aid"

const TableByBanner = "self_banner"

const BannerByStatusShow = 1 //显示
const BannerByStatusHide = 2 //隐藏

func BannerByStatusString(status int) string {
	stringMpa := map[int]string{
		UserByStatusNormal: "显示",
		UserByStatusForbid: "隐藏",
	}
	return stringMpa[status]
}

// BannerList 轮播图列表
func BannerList() *[]map[string]interface{} {
	bannerSql, args := sql_aid.PgTable(TableByBanner).Field("id", "title", "type_id", "picture", "url", "status").Where("type_id = ?", BannerByStatusShow).ToSql()
	bannerData, err := sql_aid.DataToMap(PgSql.Query(bannerSql, args...))
	if err != nil || len(bannerData) == 0 {
		return nil
	}
	return &bannerData
}
